extends ./layouts/main

block style
	link(href='/style/form.less' rel="stylesheet/less")

block content
	form(id='form').form-group
		input(type='text' name='userName' id='user').form-control
		input(type='password' name='password' id='pwd').form-control
		input(type='password' name='password' id='pwd2').form-control
		input(type='submit' value='注册').form-control
	script.
		$('#form').on('submit',function (evt) {
			evt.preventDefault();
			if($('#pwd').val() !== $('#pwd2').val()) {
				console.log('两次密码不一致');
				return ;
			}
			$.ajax({
				url:'/user/register',
				method:'POST',
				data:{
					userName:$('#user').val(),
					password:$('#pwd').val()
				},
				dataType:'json',
				success:function (data) {
					console.log(data)
					if(data.ok == 'ok') {
						window.location.href='/login';
					}
				}
			})
		})